Skip to content

Structuralization of captures #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 14, 2022

Conversation

milseman
Copy link
Member

@milseman milseman commented Feb 14, 2022

Structuralize matching engine captures, at least partially.

@milseman
Copy link
Member Author

@rxwei I have a lot of tests cases in this PR if you'd like to take a look. I'm not entirely sure what behavior we want for all of them.

@rxwei
Copy link
Contributor

rxwei commented Feb 14, 2022

Literal capture structure tests look good to me.

Did you plan to add DSL capture tests as well? For example, the following DSL

let regex = Regex {
    oneOrMore {
        capture("a")
        capture("b")
    }
} // `Regex<(Substring, [(Substring, Substring)])>`

is expected to produce Regex<(Substring, [(Substring, Substring)])> by the current design.

Unrelated to this PR: By the current DSL design, we'll have a .flatten() method which will be generated by the converter when converting literal (?:(a)(b))+.

let regex = Regex {
    oneOrMore {
        capture("a")
        capture("b")
    }.flatten()
} // `Regex<(Substring, [Substring], [Substring])>`

@milseman
Copy link
Member Author

is expected to produce Regex<(Substring, [(Substring, Substring)])>

What is matchResult.1?

@rxwei
Copy link
Contributor

rxwei commented Feb 14, 2022

[(Substring, Substring)]

@milseman milseman force-pushed the structural_captivation branch from eccd21b to 92de597 Compare February 14, 2022 21:50
@milseman milseman marked this pull request as ready for review February 14, 2022 21:51
@milseman
Copy link
Member Author

@swift-ci please test linux platform

@milseman milseman changed the title WIP: Structuralization of captures Structuralization of captures Feb 14, 2022
Copy link
Member

@natecook1000 natecook1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

func _match(
// TODO: Should we expose parameters for testing?
// Currently, tests just use the execution interface directly.
func _performLegacyMatch(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be deleted now that we don't need the VM?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CaptureTests uses this kind of functionality, but there it's hand-invoking the VM. We could delete it, unless it's useful for a match-API-based test. I was considering taking the legacy stuff out of the _StringProcessing module and put it back into the Prototypes module, at which point I believe this would move with it.

I'll follow up after this PR.

@milseman milseman merged commit ff635c6 into swiftlang:main Feb 14, 2022
@milseman milseman deleted the structural_captivation branch February 14, 2022 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants